package com.example.demo.single;

//类加载时对象未被创建可能造成同一对象被多个线程抢占
public class LH {

    private LH() {
    }

    private static LH lh;

    //懒汉模式-线程不安全
    public static LH getInstance() {
        if (lh == null) {
            return lh = new LH();
        }
        return lh;
    }

}
